/*** Eclipse Class Decompiler plugin, copyright (c) 2012 Chao Chen (cnfree2000@hotmail.com) ***/
package com.qihoo.gamecenter.sdk.support.component;

import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.FrameLayout;
import android.widget.FrameLayout.LayoutParams;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TextView;
import com.qihoo.gamecenter.sdk.common.i.s;

public class CustomTabView extends LinearLayout {
    private Activity a;
    private a[] b;
    private LinearLayout c;
    private FrameLayout d;
    private TextView[] e;
    private int f;
    private com.qihoo.gamecenter.sdk.support.d.a g;
    private View.OnClickListener h = new View.OnClickListener() {
        public void onClick(View paramView) {
            int i = ((Integer) paramView.getTag()).intValue();
            CustomTabView.this.a(i, false);
        }
    };

    public CustomTabView(Context paramContext) {
        super(paramContext);
        this.a = ((Activity) paramContext);
        this.g = com.qihoo.gamecenter.sdk.support.d.a.a(this.a);
        b();
    }

    private void b() {
        setOrientation(1);
        this.c = new LinearLayout(this.a);
        addView(this.c, new LinearLayout.LayoutParams(-1, s.b(this.a, 40.0F)));
        this.d = new FrameLayout(this.a);
        addView(this.d, new LinearLayout.LayoutParams(-1, 0, 1.0F));
    }

    public void setTabs(a[] paramArrayOfa, int paramInt) {
        if ((paramArrayOfa == null) || (paramArrayOfa.length <= 0))
            return;
        int i = paramArrayOfa.length;
        this.b = new a[i];
        this.e = new TextView[i];
        System.arraycopy(paramArrayOfa, 0, this.b, 0, i);
        paramInt = ((paramInt < 0) || (paramInt >= i)) ? 0 : paramInt;
        LinearLayout.LayoutParams localLayoutParams = new LinearLayout.LayoutParams(0, -1, 1.0F / i);
        localLayoutParams.gravity = 16;
        int j = 0;
        for (a locala : this.b) {
            TextView localTextView = new TextView(this.a);
            localTextView.setText(locala.a);
            localTextView.setGravity(17);
            localTextView.setTextColor(Color.parseColor("#979797"));
            localTextView.setBackgroundColor(-1);
            localTextView.setTextSize(1, s.a(this.a, 14.7F));
            localTextView.setTag(Integer.valueOf(j));
            localTextView.setOnClickListener(this.h);
            this.g.a(localTextView, locala.c[0], locala.c[1], 0);
            this.c.addView(localTextView, localLayoutParams);
            this.e[j] = localTextView;
            ++j;
        }
        a(paramInt, true);
    }

    public a a() {
        return this.b[this.f];
    }

    public void a(int paramInt, boolean paramBoolean) {
        if ((this.f == paramInt) && (!(paramBoolean)))
            return;
        s.a(this.a);
        this.d.removeAllViews();
        this.e[this.f].setTextColor(Color.parseColor("#979797"));
        this.e[paramInt].setTextColor(Color.parseColor("#FF8A00"));
        this.g.a(this.e[this.f], this.b[this.f].c[0]);
        this.g.a(this.e[paramInt], this.b[paramInt].c[1]);
        this.d.addView(this.b[paramInt].b.c(), new FrameLayout.LayoutParams(-1, -1));
        this.b[this.f].b.a();
        this.b[paramInt].b.b();
        this.f = paramInt;
    }

    public class a {
        public String a;
        public a b;
        public int[] c = { 0, 0 };
    }
}